package com.mew.slots.core.game.hjtg.service;

import com.mew.common.entity.game.WinFree;
import com.mew.slots.core.common.game.BaseGameService;
import com.mew.slots.core.common.game.vo.BasePlayMsgs;
import com.mew.slots.core.common.messge.response.SlotsPlayResponseMessage;
import com.mew.slots.core.common.vo.StrategyGameVO;
import com.mew.slots.core.game.hjtg.bo.HjtgPlayMsgs;
import com.mew.slots.core.game.hjtg.message.HjtgResponseMessage;
import com.mew.slots.core.game.hjtg.roller.HjtgXml;
import com.mew.slots.core.game.hjtg.room.HjtgRoom;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author Dylin
 */
@Service
@Slf4j
public class HjtgService extends BaseGameService {
    @Override
    public BasePlayMsgs startGame(StrategyGameVO player) {
        int rc = (winFree.getFreeCount() - winFree.getFreeNumber()) % 3 + 1;
        HjtgRoom room = new HjtgRoom(rc);
        room.init(player.getRollerId(), HjtgXml.getInstance(),player.getWinFree().getFrees()>0,player.getInBetNumber(),player.getControlType());
        room.roundPlay();
        return room.getRes();
    }

    @Override
    public SlotsPlayResponseMessage myResp(WinFree winFree, BasePlayMsgs res) {
        HjtgResponseMessage message = new HjtgResponseMessage();
        HjtgPlayMsgs pmres = (HjtgPlayMsgs) res;

        message.setRc(pmres.getRc());
        message.setIndex(pmres.getIndex());
        return message;
    }
    @Override
    public void myAfterResp(SlotsPlayResponseMessage message,StrategyGameVO player, BasePlayMsgs res) { }
}
